﻿<%@ Page Language="C#" AutoEventWireup="true"  Inherits="ZX.Web.UI.Controls.DataGrid" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
 <title></title>
    <link href="/Scripts/JQuery_zTree_v3.3/css/zTreeStyle/zTreeStyle.css" rel="stylesheet"  type="text/css" />
    <link href="/Scripts/JQuery_zTree_v3.3/css/demo.css" rel="stylesheet" type="text/css" />
    <!--CSS file (default YUI Sam Skin) -->
    <link rel="stylesheet" type="text/css" href="../scripts/yui_2.9.0/build/reset-fonts-grids/reset-fonts-grids.css" />
    <link rel="stylesheet" type="text/css" href="../scripts/yui_2.9.0/build/container/assets/skins/sam/container.css" />
    <link rel="stylesheet" type="text/css" href="../scripts/yui_2.9.0/build/resize/assets/skins/sam/resize.css" />
    <link rel="stylesheet" type="text/css" href="../scripts/yui_2.9.0/build/layout/assets/skins/sam/layout.css" />
    <link href="/ExtendPage/Template/matrix-1/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
    .yui-skin-sam table {
	  width: 100%; 
    }
    input[type=text]
    {
        height:15px;
        line-height:16px;
        font-size:12px;
    }
    input[type=button]
    {
        height:15px;
        line-height:16px;
        font-size:12px;
    }
    .headcol {
        position:relative;
        /*width:5em;*/
        left:0;
        top:auto;
        border-right: 0px none black;
        border-top-width:3px; /*only relevant for first row*/
        margin-top:-3px; /*compensate for top border*/
    }
    #button-example-form fieldset, 
    #button-example-form fieldset div {
        border: 2px groove #ccc;
        margin: .5em;
        padding: .5em;
    }
    .yui-layout-unit-bottom 
    {
       border:0px;
    }
    
    #yui-gen6
    {
        border:0px;
    }
    #carlendar_div
    {
        background-color:#eee;
        border:1px solid #ddd;
    }
    #carlendar_div input
    {
        width:40px;
    }

</style>
</head>
<body class="yui-skin-sam">
    <form id="form1" runat="server">
    <!-- 左栏 -->
    <div id="leftPanel">
         <ul class='ztree' id='TreeData' style="width: 100%; height: 100%; border: 0px; margin: -5px;">
        </ul><input id="SN" type="hidden"/>
        <input id="NewStatus" type="hidden"/>
        <input id="CheckedImages" type="hidden"/>
    </div>
    <!-- 左栏 -->
    <!-- 工具栏 -->
    <div id="toolbar" style="margin: 2px;">
       <div class="btn-group" data-toggle="buttons-radio"> <% =BtnItems %></div>
     </div> 
    <div id="data" style="margin:0px;">
            <iframe id="dataDatailWindow" frameborder="0" style="width: 100%; height: 100%;margin: 0px; padding: 0px;" src="/ExtendPage/CtrlPage/FileListData.aspx?&entity=t_File&path=/"></iframe>
    </div>
    <!-- 对话框 -->
    <div id="dialogArea">
    <div id="dialog1" class="yui-pe-content"  >
        <div class="hd">
           <% =PageTitle %>数据编辑</div>
        <div class="bd" >
            <iframe id="EditUIWindow" frameborder="0" src="" style="width: 100%; height: 100%;
                margin: 0px; padding: 0px;"></iframe>
        </div>
    </div>
        
    <div id="dialog2" class="yui-pe-content" >
        <div class="hd">
            文件上传:</div>
        <div class="bd">
            <iframe id="EditUIWindow1" frameborder="0" src="" style="width: 100%; height: 100%;
                margin: 0px; padding: 0px;"></iframe>
        </div>
    </div>
    <div id="dialog3" class="yui-pe-content"  >
        <div class="hd">
            提示</div>
        <div class="bd">
            你正在删除当前选择的数据，继续请按确定？
        </div>
    </div>
    </div>
    </form>
</body>


<script type="text/javascript" src="/Scripts/yui_2.9.0/build/yahoo-dom-event/yahoo-dom-event.js"></script>
<script type="text/javascript" src="/Scripts/yui_2.9.0/build/element/element-min.js"></script>
<script type="text/javascript" src="/Scripts/yui_2.9.0/build/datasource/datasource-min.js"></script>
<script type="text/javascript" src="/Scripts/yui_2.9.0/build/json/json-min.js"></script>
<script type="text/javascript" src="/Scripts/yui_2.9.0/build/connection/connection-min.js"></script>
<script type="text/javascript" src="/Scripts/yui_2.9.0/build/get/get-min.js"></script>
<script type="text/javascript" src="/Scripts/yui_2.9.0/build/dragdrop/dragdrop-min.js"></script>
<script type="text/javascript" src="/Scripts/yui_2.9.0/build/datatable/datatable-min.js"></script>
<script type="text/javascript" src="/Scripts/yui_2.9.0/build/paginator/paginator-min.js"></script>
<script type="text/javascript" src="/scripts/yui_2.9.0/build/layout/layout-min.js"></script>
<script type="text/javascript" src="/scripts/yui_2.9.0/build/container/container-min.js"></script>
<script type="text/javascript" src="/scripts/yui_2.9.0/build/resize/resize-min.js"></script>
<script type="text/javascript" src="/scripts/yui_2.9.0/build/event-delegate/event-delegate-min.js"></script>

<script src="/Scripts/jquery-1.6.min.js" type="text/javascript"></script>
<script src="/Scripts/Jquery.form.js" type="text/javascript"></script>
<script src="/Scripts/JQuery_zTree_v3.3/js/jquery.ztree.core-3.3.js" type="text/javascript"></script>
<script src="/Scripts/JQuery_zTree_v3.3/js/jquery.ztree.excheck-3.3.js" type="text/javascript"></script>
<script src="/Scripts/JQuery_zTree_v3.3/js/jquery.ztree.exedit-3.3.js" type="text/javascript"></script>
<script type="text/javascript" src="/Scripts/ArrayToJson.js"></script>
<script src="/Scripts/jquery.data.js" type="text/javascript"></script> 
<script src="/Scripts/jquery.calendar.js" type="text/javascript"></script>
<script type="text/javascript">
    var const_entityID = "<% =EntityId %>",    //实体ID名称
        const_entityName = "<% =EntityName %>",//实体名称
        const_EditEntity = "<% =EditEntity %>",//编辑实体名
        const_functionId   ="<% =FunctionID %>",//自定义条件
        const_Order ="<% =Order %>",           //排序  
        const_UserId = "<% = UserId %>",       //
        const_DataFields = [<% =DataFields %>],
        const_DataColums = [<% =DataColums %>],
        const_QueryField="<% =QuciklyQueryFields %>",
        const_EditWindowWidth = "<% =EditWindowWidth %>px",
		const_EditWindowHeight = "<% =EditWindowHeight %>px",
        const_PageTitle=encodeURI("<% =PageTitle %>"),
        editpageFlag = 0,
        _EditDataURL="",
        selectControl=null,                       
        requireUrl="",
        const_CurID = "",//当前所选ID
        const_CurTreeNode,
        //initialRequestUrl = "pageindex=1&entity=" + const_entityName + "&order="+const_Order+"&r="+Math.random()+"&zip=94089&results=10&output=json&functionid="+const_functionId+"&customCondition="+ const_CustomCondition,
        //initialRequestUrl = "pageindex=0&entity=" + const_entityName + "&order="+const_Order+"&r="+Math.random()+"&zip=94089&results=10&output=json&functionid="+const_functionId+"&customCondition="+ const_CustomCondition+"&condition="+const_Condition,
        SaveUrl,dl;//要删除的数据列  
</script>
<script type="text/javascript">
    var _functionid= getPar1("functionid");

    //var _id = 
    /* 树 */
    var setting = {
    	view: {
		    nameIsHTML: true
        },
        edit: {
            drag: {
                autoExpandTrigger: true,
                prev: dropPrev,
                inner: dropInner,
                next: dropNext
            },
            enable: true,
            showRemoveBtn: false,
            showRenameBtn: false,
            editNameSelectAll: false

        },
        data: {
            key: {
                title: "t"
            },
            simpleData: {
                enable: true
            }
        },
        callback: {
            beforeClick: beforeClick,
            onClick: onClick,
            beforeDrag: beforeDrag,
            beforeDrop: beforeDrop,
            beforeDragOpen: beforeDragOpen,
            onDrag: onDrag,
            onDrop: onDrop,
            onExpand: onExpand
        }
    };


    var DutyInfosetting = {
        edit: {
            enable: true,
            showRemoveBtn: false,
            showRenameBtn: false
        },
        data: {
            simpleData: {
                enable: true
            }
        },
        callback: {
            beforeDrag: beforeDrag,
            beforeDrop: beforeDrop
        }
    };

    var log, className = "dark";
    function beforeClick(treeId, treeNode, clickFlag) {
        className = (className === "dark" ? "" : "dark");
        return (treeNode.click != false);
    }

    function onClick(event, treeId, treeNode, clickFlag) {
        //alert(treeNode.DirPath+":"+treeNode.name);
        //const_CurID = treeNode.realID;
        //const_CurTreeNode = treeNode;
        $("#dataDatailWindow")[0].src = "/ExtendPage/CtrlPage/FileListData.aspx?functionid=" + _functionid + "&r=" + Math.random() + "&entity=t_File&path=" + treeNode.DirPath;

    }


    function show() {
        //alert($("#SN").val());
        AddRootChlidNode($("#SN").val(), $("#SN").val(), true);
    }

    function getProduct(SN) {
        var data = fnGetData("V_GS_Product", "SN='" + SN + "'", "SN");
        return data;
    }

//    setTimeout(function () {
//        var zTree = $.fn.zTree.getZTreeObj("TreeData");
//        var _root = zTree.getSelectedNodes()[0];
//        //debugger
//    }, 10000);


//    function createWindow(imageURL, fileName) {
//        $.window({
//            //showModal: true,
//            modalOpacity: 0.5,
//            icon: "",
//            title: fileName,
//            content: "<img src='" + imageURL + "' width='99%'/>",
//            footerContent: "<div style='color:gray;'>" + fileName + "</div>"
//        });
//    }


    function DeleteNodes() {
        var zTree = $.fn.zTree.getZTreeObj("TreeData");
        var _newNode = zTree.getNodeByParam("id", id, null);
        if (_newNode != null && typeof (_newNode) != "undefined") {
            zTree.removeChildNodes(_newNode);
            zTree.removeNode(_newNode, null);
        }
 
    }


    function AddRootChlidNode(id, name) {
        if (typeof (fnCustomAddChildNode) == "function") {
        } else {
            var zTree = $.fn.zTree.getZTreeObj("TreeData");
            var _root = zTree.getNodes()[0];
        }
    }

    function AddNewNode(id, name, bl) {
        //debugger
        var zTree = $.fn.zTree.getZTreeObj("TreeData");
        if (const_CurTreeNode == null ||typeof( const_CurTreeNode) == "undefined") {
            const_CurTreeNode = zTree.getSelectedNodes()[0];
        }
        //debugger
        if (id == const_CurTreeNode.id) {
            var _node = zTree.getNodeByTId(id);
            zTree.selectNode(_node);
            return;
        } else {
            //alert(bl);
            if (bl) {
                zTree.addNodes(const_CurTreeNode, { id: id, pId: const_CurTreeNode.id, name: name, SN: name });
            } else {
                var _node = zTree.getNodeByTId("root");
                zTree.addNodes(_node, { id: id, pId: _node.id, name: name, SN: name });
            }
            var _node = zTree.getNodeByTId(id);
            zTree.selectNode(_node);

        }
    }

    function addHoverDom(treeId, treeNode) {
        //debugger
        var sObj = $("#" + treeNode.tId + "_span");
        if (treeNode.editNameFlag || $("#addBtn_" + treeNode.id).length > 0) return;
        var addStr = "<span class='button add' id='addBtn_" + treeNode.id
				+ "' title='add node' onfocus='this.blur();'></span>";
        sObj.after(addStr);
        var btn = $("#addBtn_" + treeNode.id);
        if (btn) btn.bind("click", function () {
            var zTree = $.fn.zTree.getZTreeObj("orgTree");
            zTree.addNodes(_treeNode, { id: (100 + newCount), pId: _treeNode.id, name: "new node" + (newCount++) });
            return false;
        });
    };
    function beforeDragOpen(treeId, treeNode) {
    }

    function beforeDrag(treeId, treeNodes) {
    }

    function beforeDrop(treeId, treeNodes, targetNode, moveType) {
    }

    function dropPrev(treeId, nodes, targetNode) {
    }

    function dropInner(treeId, nodes, targetNode) {

    }

    function dropNext(treeId, nodes, targetNode) {
    }

    function onDrag(event, treeId, treeNodes) {
    }

    function onDrop(event, treeId, treeNodes, targetNode, moveType, isCopy) {
    }

    function onExpand(event, treeId, treeNode) {
    }


    (function () {
        var Dom = YAHOO.util.Dom,
            Event = YAHOO.util.Event;
        Event.onDOMReady(function () {
            var layout = new YAHOO.widget.Layout({
                minWidth: 1000,
                minHeight: 500,
                units: [
                    { position: 'left', width: 200,  resize: true, body: 'leftPanel', gutter: '0px 5px 0px 0px', collapseSize: 50, scroll: true, maxWidth: 300 },
                    { position: 'center', minWidth: 400, minHeight: 200 }
                ]
            });
            layout.on('render', function () {
                var el = layout.getUnitByPosition('center').get('wrap');
                var layout2 = new YAHOO.widget.Layout(el, {
                    parent: layout,
                    minWidth: 400,
                    minHeight: 200,
                    units: [
                         { position: 'top', body: 'toolbar', height: 35, gutter: '0px', maxHeight: 80 },                        
                        { position: 'center', body: 'data', gutter: '0px', scroll: true }
                    ]
              });
              layout2.render();
            });
            layout.render();
            InitLeftData();
            fnResize() ;
        });
            //$("#dataDatailWindow").height($("#data").height());
    })();



    //
    function InitLeftData() {
        $.get("/Extend/AjaxData/JsonList.aspx?r=" + Math.random() + "&action=getdirs",
            function (d, t) {
                //
                var data = eval("(" + d + ")");
                var _temp = [];
                $.each(data, function (e) {
                    _temp.push($.extend(data[e], { drag: true,name:data[e].Dir,id:data[e].DirPath,pId:data[e].ParentPath }));
                });
                $.fn.zTree.init($("#TreeData"), setting, _temp);
                //debugger
            });
    }

    function fnResize() {
        $("#data").height($(window).height()-5);
    }

    function fnOpenFile(filePath) {
        _EditDataURL = "/ExtendPage/CtrlPage/FileEditor.aspx?path=" + filePath;
        $("#btn_window_open").click();


    }

    function fnRefresh() {
//        var editwindow = document.getElementById("dataDatailWindow");
//        if (editwindow) {
//            editwindow.contentWindow.initImageList();
//        }
    }

    function GetSelectedImages() {
        var editwindow = document.getElementById("dataDatailWindow");
        if (editwindow) {
            return (editwindow.contentWindow.GetSelectedImages());
        }
        return "";
    }


    $(window).resize(function () {
        fnResize();
    });




    // Define various event handlers for Dialog
    var handleSubmit = function () {
        var editwindow = document.getElementById("EditUIWindow");
        if (editwindow) {
            editwindow.contentWindow.Save();
        }
    };

    var handleCancel = function () {
        this.cancel();
    };

    var handleSubmit1 = function () {
        var editwindow = document.getElementById("EditUIWindow1");
        if (editwindow) {
            editwindow.contentWindow.ChooseInfo();
        }
        this.cancel();
        //YAHOO.example.container.dialog2.hide();
    }
    var handleSuccess = function (o) {
        var response = o.responseText;
        response = response.split("<!")[0];
        document.getElementById("resp").innerHTML = response;
    };
    var handleFailure = function (o) {
        alert("提交失败: " + o.status);
    };


    /* -----------------------------------------
    *  定义对话窗口功能
    *  
    *
    *
    *--------------------------------------------*/
    //YAHOO.util.Event.addListener(window, "load", BindData);
    YAHOO.namespace("example.container");
    YAHOO.util.Event.onDOMReady(function () {


        // Remove progressively enhanced content class, just before creating the module
        YAHOO.util.Dom.removeClass("dialog1", "yui-pe-content");

        /*
        数据编辑
    
        */
        //debugger
        YAHOO.example.container.dialog1 = new YAHOO.widget.Dialog("dialog1",
							    { width: const_EditWindowWidth,
							        height: const_EditWindowHeight,
							        fixedcenter: true,
							        visible: false,
							        draggable: true,
							        close: true,
							        max: true,
							        autofillheight: "body",
							        modal: true,
							        constraintoviewport: true,
							        buttons: [{ text: "保存", handler: handleSubmit, isDefault: true },
								          { text: "取消", handler: handleCancel}]
							    });

        /*
    
        */
        YAHOO.example.container.dialog2 = new YAHOO.widget.Dialog("dialog2",
							    { width: "650px",
							        height: "480px",
							        fixedcenter: true,
							        visible: false,
							        draggable: true,
							        close: true,
							        modal: true,
							        autofillheight: "body",
							        constraintoviewport: true,
							        buttons: [
								          { text: "取消", handler: handleCancel}]
							    });

        /*
    
        */
        YAHOO.example.container.dialog3 = new YAHOO.widget.Dialog("dialog3",
							    { width: "350px",
							        height: "100px",
							        fixedcenter: true,
							        visible: false,
							        draggable: true,
							        close: true,
							        modal: true,
							        autofillheight: "body",
							        constraintoviewport: true,
							        buttons: [{ text: "确定", handler: DeleteData, isDefault: true },
								          { text: "取消", handler: handleCancel}]
							    });

        /*
        查询
        */
        YAHOO.example.container.dialog4 = new YAHOO.widget.Dialog("dialog4",
							    { width: "650px",
							        height: "350px",
							        fixedcenter: true,
							        visible: false,
							        draggable: true,
							        close: true,
							        modal: true,
							        autofillheight: "body",
							        constraintoviewport: true,
							        buttons: [
							    { text: "取消", handler: handleCancel}]
							    });
        YAHOO.example.container.dialog5 = new YAHOO.widget.Dialog("dialog5",
							    { width: const_EditWindowWidth,
							        height: const_EditWindowHeight,
							        fixedcenter: true,
							        visible: false,
							        draggable: true,
							        close: true,
							        modal: true,
							        autofillheight: "body",
							        constraintoviewport: true,
							        buttons: [
							    { text: "取消", handler: handleCancel}]
							    });
        // Validate the entries in the form to require that both first and last name are entered


        // Wire up the success and failure handlers
        YAHOO.example.container.dialog1.callback = { success: handleSuccess,
            failure: handleFailure
        };

        // Render the Dialog
        YAHOO.example.container.dialog1.render(); //编辑对话框
        YAHOO.example.container.dialog2.render(); //删除对话框
        YAHOO.example.container.dialog3.render(); //
        YAHOO.example.container.dialog4.render(); //
        YAHOO.example.container.dialog5.render(); //
    });


    $(document).ready(function () {
        $("#toolbar>.btn-group>button").addClass("btn");
        $("#toolbar>.btn-group>button").addClass("btn-info");
        $("#toolbar>.btn-group>span").addClass("btn-mini");
        setTimeout(function () {
            $("button").addClass("btn");
            $("button").addClass("btn-info");
        }, 100)
    });



    // 设置对话框的大小
    var SetDWH = function (width, height, dialog) {

        var elements = YAHOO.util.Dom.getElementsByClassName('bd', 'div')[0];
        var w = [],
        h = [];
        w.push(width);
        h.push(height);
        dialog.configWidth(null, w);
        dialog.configHeight(null, h);

        dialog.render();
        if (elements) {
            dialog.fillHeight(elements);
        }
    }
    // 设窗口最大化
    var SetMaxDWH = function (dialog) {

        var w = YAHOO.util.Dom.getViewportWidth() - 20;
        var h = YAHOO.util.Dom.getViewportHeight() - 20;
        SetDWH(w, h, dialog);
    }

    var SetNorDWH = function (dialog) {
        SetDWH(const_EditWindowWidth, const_EditWindowHeight, dialog);
    }
    //$("#datCon").datepicker();
</script> 
<script src="/Scripts/yui.list.button.event.js" type="text/javascript"></script>
<script src="/Scripts/ctrls/jquery.fixed.windows.js" type="text/javascript"></script>
<script src="/Scripts/ctrls/jquery.fixed.dialog.js" type="text/javascript"></script>
</html>
